<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <link href="static/css/metro.css" rel="stylesheet">
    <link href="static/css/main.css" rel="stylesheet"> 
    <script src="static/js/jquery.js"></script>
    <script src="static/js/metro.js"></script>
    <script src="static/js/crypto-js.js"></script>    
    <script src="static/js/hmac-sha1.js"></script>        
    <script type='text/javascript'>
        $(document).ready(function(){
            // Enter Fullscreen mode on load. Only effects in Firefox.
            // To enable it you need to change 
            // full-screen-api.allow-trusted-requests-only to false.
            document.documentElement.mozRequestFullScreen(); //
            scroll(0,0);
            //alert('hello world!');
            ShowTime();
            getWeather();
            getInform();
        });
        /* function getWeather(){
            querystr = 'ts='+Math.round(new Date().getTime()/1000)+'&ttl=30&uid=UF07904EEB'
            key = 'dgm5vnlh5aszoifb'
            sig = CryptoJS.HmacMD5(querystr, key)
            querystr = querystr+ '&sig=' + sig
            $.getJSON('https://api.thinkpage.cn/v3/weather/now.json&' + sig, function(json){
                console.log(json);
            });
        } */
        function getWeather(){
            $.getJSON('/_getweather.json', function(json){
                // Data Format:
                // {'wname': '晴', 'windex': '1', 'temp': '23'}
                $('#weathername').text(json.wname);
                $('img#weatherthumb').attr('src', '/static/img/w_icon/'+json.windex+'.svg');
                $('#wtemp').text(json.temp);
            });
            setTimeout('getWeather()', 300000);
        }
        function getInform() {
            $.getJSON('/_article', function(json){
                // Data Format:
                // {'wname': '晴', 'windex': '1', 'temp': '23'}
                $('#informtitle').text(json.title);
                $('#informbody').text(json.body)
            });
            setTimeout('getInform()', 30000);
        }
        function ShowTime(){
            var NowDate=new Date();
            var month=NowDate.getMonth()+1;
            var date=NowDate.getDate();
            var day=NowDate.getDay();
            var weekday=new Array(7)
            weekday[0]="星期日"
            weekday[1]="星期一"
            weekday[2]="星期二"
            weekday[3]="星期三"
            weekday[4]="星期四"
            weekday[5]="星期五"
            weekday[6]="星期六"
            var h=NowDate.getHours();
            if (h < 10) h = '0' + h;
            var m=NowDate.getMinutes();
            if (m < 10) m = '0' + m;
            var s=NowDate.getSeconds();
            if (s < 10) s = '0' + s;
            $('#datebox').text(month+'月'+date+'日 '+weekday[day]);
            $('#showbox').text(h+':'+m+':'+s);
            // setTimeout('ShowTime()',7200000);
            setTimeout('ShowTime()',1000);
        }
    </script>
</head>
<body>
    <div class='container'>
        <div class="grid">
            <div class="row cells2">
                <div class="cell">
                    <img src='static/img/logo.png' id='logo'>
                </div>
                <div class='cell' style='height: 90px; display:table'>  
                </div>
            </div>
            <div class="row cells3">
                <div class='cell'>
                    <div class='panel'>
                        <div class='heading'>
                            <span class='title'>南京天气</span>
                        </div>
                        <div class='content padding10'>
                            <div id='weather-cell'>
                                <h3 style='text-align: center'><div id="datebox"></div></h3>
                                <h3 style='text-align: center'><div id="showbox"></div></h3>
                                <div class='thumbnail'>
                                    <img src='static/img/weather.svg' id='weatherthumb' width="100" height="100" style='text-align: center' />
                                </div>
                                <h4 style='text-align: center'><div id='weathername'>多云</div></h4>
                                <h4 style='text-align: center'><div id='wtemp'>16</div>&deg;</h4>
                            </div>
                        </div>
                    </div>
                </div>
                <div class='cell'>
                    <div class="panel">
                        <div class="heading">
                            <span class="title">今日安排</span>
                        </div>
                        <div class="content padding0">
                            <div class="carousel" data-role="carousel" data-height="280" data-controls="false" data-period="10000">                    
                                {% if eve is none %}
                                <div class='slide padding20'>
                                    <h3>今日暂无安排</h3>
                                </div>
                                {% else %}
                                {% for i in eve %}
                                <div class="slide padding20">
                                    <h3>{{ i['theme'] }}</h3>
                                    <ul> 
                                        <li><div class='justify'>时 间</div>: {{ i['time'] }}</li>
                                        <li><div class='justify'>地 点</div>: {{ i['location'] }}</li>
                                        {% if i['attendee'] %}
                                        <li><div class='justify'>参加人员</div>: {{ i['attendee'] }}</li>
                                        {% endif %}
                                    </ul>
                                </div>
                                {% endfor %}
                                {% endif %}
                                <!--
                                <div class="slide padding20">
                                    <h3>江苏省委宣讲团贯彻党代会精神集中宣讲活动</h3>
                                    <ul>
                                        <li><div class='justify'>时间</div>: 14:30</li>
                                        <li><div class='justify'>地点</div>: 大报告厅</li>
                                        <li><div class='justify'>主持人</div>: 王邱文</li>
                                        <li><div class='justify'>牵头部门</div>: 宣教处</li>
                                        <li><div class='justify'>参加人员</div>: 校领导、中层干部、党总支（直属支部）委员、党支部书记、党校入党教育对象</li>
                                    </ul>
                                </div>
                                -->
                                <!--<div class='slide padding20'>
                                    <h3>今日暂无安排</h3>
                                </div> -->
                            </div>
                        </div>
                    </div>
                </div>
                <div class='cell'>
                    <div class="panel">
                        <div class="heading">
                            <span class="title">系部通知</span>
                        </div>
                        <div class="content padding20">
                            <h3 id='informtitle'></h3>
                            <p style='line-height:150%;' id='informbody'></p>
                        </div>
                    </div>
                </div>
            </div>
            <h2 id='bottom'>信息技术系 电子公告栏</h3>
            <p id='copy'><!--&copy; IT.D Nanjing Forest Police College.--> &copy; 网安工作室 设计研发</p>
        </div>
    </div>
</body>
</html>
